<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@taglib prefix="f" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!DOCTYPE html>
<html>
<head lang="en">
    <meta charset="UTF-8">
    <title>超市账单管理系统</title>
    <link rel="stylesheet" href="${pageContext.request.contextPath}/css/public.css"/>
    <link rel="stylesheet" href="${pageContext.request.contextPath}/css/style.css"/>
</head>
<body>
<!--头部-->
    <header class="publicHeader">
        <h1>超市账单管理系统</h1>
        <div class="publicHeaderR">
            <p><span>下午好！</span><span style="color: #fff21b"> Admin</span> , 欢迎你！</p>
            <a href="../../login.jsp">退出</a>
        </div>
    </header>
<!--时间-->
    <section class="publicTime">
        <span id="time">2015年1月1日 11:11  星期一</span>
        <a href="#">温馨提示：为了能正常浏览，请使用高版本浏览器！（IE10+）</a>
    </section>
<!--主体内容-->
    <section class="publicMian ">
        <div class="left">
            <%@include file="left.jsp"%>
        </div>
        <div class="right">
            <%@include file="right.jsp"%>
            <div class="search">
                <span>商品名称：</span>
                <input type="text" placeholder="请输入商品的名称"/>
                
                <span>供应商：</span>
                <select name="tigong" >
                    <option value="">--请选择--</option>
                    <option value="">北京市粮油总公司</option>

                </select>

                <span>是否付款：</span>
                <select name="fukuan">
                    <option value="">--请选择--</option>
                    <option value="">已付款</option>
                    <option value="">未付款</option>
                </select>

                <input type="button" value="查询"/>
                <a href="${pageContext.request.contextPath}/page/billAdd">添加订单</a>
            </div>
            <!--账单表格 样式和供应商公用-->
            <table class="providerTable" cellpadding="0" cellspacing="0">
                <tr class="firstTr">
                    <th width="10%">账单编码</th>
                    <th width="20%">商品名称</th>
                    <th width="10%">供应商</th>
                    <th width="10%">账单金额</th>
                    <th width="10%">是否付款</th>
                    <th width="10%">创建时间</th>
                    <th width="30%">操作</th>
                </tr>



                <c:forEach items="${billList}" var="bill">
                <tr>
                    <td>${bill.billcode}</td>
                    <td>${bill.productname}</td>
                    <td>${bill.provider.proname}</td>
                    <td>${bill.totalprice}</td>
                    <td>
                        <c:if test="${bill.ispayment==1}">已付款</c:if>
                        <c:if test="${bill.ispayment==2}">未付款</c:if>
                    </td>
                    <td>
                        <f:formatDate value="${bill.creationdate}" pattern="yyyy-MM-dd"></f:formatDate>
                    </td>
                    <td>
                        <a href="${pageContext.request.contextPath}/bill/${bill.id}"><img src="${pageContext.request.contextPath}/img/read.png" alt="查看" title="查看"/></a>
                        <a href="${pageContext.request.contextPath}/bill/update/${bill.id}"><img src="${pageContext.request.contextPath}/img/xiugai.png" alt="修改" title="修改"/></a>
                        <a href="javascript:void(0)" bid="${bill.id}" class="removeBill"><img src="${pageContext.request.contextPath}/img/schu.png" alt="删除" title="删除"/></a>
                    </td>
                </tr>
               </c:forEach>
            </table>
        </div>
    </section>

<!--点击删除按钮后弹出的页面-->
<div class="zhezhao"></div>
<div class="remove" id="removeBi">
    <div class="removerChid">
        <h2>提示</h2>
        <div class="removeMain">
            <p>你确定要删除该订单吗？</p>
            <a href="#" id="yes">确定</a>
            <a href="#" id="no">取消</a>
        </div>
    </div>
</div>



<script src="${pageContext.request.contextPath}/js/jquery.js"></script>
<script src="${pageContext.request.contextPath}/js/js.js"></script>
<script src="${pageContext.request.contextPath}/js/time.js"></script>

<script type="text/javascript">
    var tr;
    var id;
    //订单管理页面上点击删除按钮弹出删除框(billList.jsp)
    $(function () {

        $('.removeBill').click(function () {
            id=$(this).attr("bid");
            tr=$(this).parent().parent();
            $('.zhezhao').css('display', 'block');
            $('#removeBi').fadeIn();
        });
    });

    $(function () {
        $('#no').click(function () {
            $('.zhezhao').css('display', 'none');
            $('#removeBi').fadeOut();
        });
    });

    $(function () {

            $('#yes').click(function () {

                $.ajax({
                    url:"${pageContext.request.contextPath}/bill/del",
                    type:"post",
                    data:{"id":id},//发送到前台的数据（到服务器的数据）
                    dataType:"text",//后台返回的数据类型
                    success:function (data) {

                        if(data=="true") {
                            //删除当前行
                            tr.remove();
                        }
                    }

                });
                //隐藏对话框
                $('.zhezhao').css('display', 'none');
                $('#removeBi').fadeOut();


            });
    });


</script>




</body>
</html>